<template>
    <div class="search">
        <span class="nj">年级：</span>
        <el-select v-model="value" placeholder="请选择">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
        </el-select>
        <el-button class="btn" @click="inquire" type="primary">查询</el-button>
        <el-button class="btn" @click="addList" type="primary">添加</el-button>
    </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
    data() {
        return {
            value: '',
            options: [
                {
                    level: 1,
                    value: '一年级'
                },
                {
                    level: 2,
                    value: '二年级'
                },
                {
                    level: 3,
                    value: '三年级'
                },
                {
                    level: 4,
                    value: '四年级'
                },
                {
                    level: 5,
                    value: '五年级'
                },
                {
                    level: 6,
                    value: '六年级'
                },
                {
                    level: 7,
                    value: '初一'
                },
                {
                    level: 8,
                    value: '初二'
                },
                {
                    level: 9,
                    value: '初三'
                },
                {
                    level: 10,
                    value: '高一'
                },
                {
                    level: 11,
                    value: '高二'
                },
                {
                    level: 12,
                    value: '高三'
                }
            ],
        }
    },
    methods: {
        // 添加
        addList() {
            window.sessionStorage.setItem('row', "true")
            this.$router.push("/education/redact")
        },
        // 查询
        inquire() {
            let arr1 = []
            this.EStableData1.forEach(item => {
                if (item.levelName == this.value) {
                    arr1.push(item)
                }
            })
            this.value != "" ? this.$store.state.EStableData = arr1 : this.$store.state.EStableData
        },
    },
    computed: {
        ...mapState(['EStableData1']),
    }

}
</script>

<style lang="scss" scoped>
.search {
    margin-left: 15px;

    .nj {
        font-size: 14px;
        font-weight: 100;
    }

    .btn {
        margin-left: 8px;
    }
}
</style>